﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ThouShaltNotBrick.Models;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
using Microsoft.Xna.Framework.Content.Pipeline;
using ThouShaltNotBrick.PipelineExtension.Readers;

namespace ThouShaltNotBrick.PipelineExtension
{
    [ContentTypeWriter]
    public sealed class CampaignsContentTypeWriter : ContentTypeWriter<CampaignsData>
    {
        #region Overriden Methods
        protected override void Write(ContentWriter pOutput, CampaignsData pValue)
        {
            // NUMBER OF CAMPAIGNS (int)
            //   NAME (string)

            List<string> campaignList = pValue.GetCampaigns();
            pOutput.Write(campaignList.Count);
            foreach (string campaignName in campaignList)
            {
                pOutput.Write(campaignName);
            }
        }

        public override string GetRuntimeReader(TargetPlatform pTargetPlatform)
        {
            return typeof(CampaignsContentTypeReader).AssemblyQualifiedName;
        }

        public override string GetRuntimeType(TargetPlatform pTargetPlatform)
        {
            return typeof(CampaignsData).AssemblyQualifiedName;
        }
        #endregion
    }
}